<?php
/**
 * Class for elements to which it's possible to add Validators
 *
 */
abstract class Validatable extends HTMLElement
{
	private $validators = array();	
	private $error;
	
	public function addValidator(Validator $validator)
	{
		$this->validators[] = $validator;
	}
	
	public function validate()
	{
		foreach($this->validators as $validator)
		{
			if(!$validator->validate($this))
			{
				return false;
			}			
		}
		return true;
	}
	
	public function clear()
	{
		$this->value = null;
	}
	
	
	public function getError()
	{
		return $this->error;
	}
	public function setError($error)
	{
		 $this->error = $error;
	}
	
	
}